//
//  BaseViewController.m
//  ProjectDemo
//
//  Created by IOS3 on 2018/10/24.
//  Copyright © 2018 IOS3. All rights reserved.
//

#import "BaseViewController.h"


@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColor.whiteColor;
    self.loadingCount = 0;
    self.showDefaultHUD = YES;
    
}


#pragma mark -
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
}
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    
}

#pragma mark - MJRefresh
- (void)refreshData {
    
}
- (void)loadMoreData {
    
}


#pragma mark - tableView delegate & datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewCell.new;
}


- (void)setLoadingCount:(NSInteger)loadingCount {
    if (self.isShowDefaultHUD) {
        if (_loadingCount == 0 && loadingCount > 0) {
            [MBProgressHUD showLoadToView:self.view];
        }
        else if (_loadingCount > 0 && loadingCount == 0) {
            [MBProgressHUD hideHUDForView:self.view];
        }
    }
    _loadingCount = loadingCount;
}




- (BOOL)shouldAutorotate {
    return NO;
}



- (void)setTableView:(UITableView *)tableView {
    _tableView = tableView;
    _tableView.delegate = self;
    _tableView.dataSource = self;
    if (@available(iOS 11, *)) {
        _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways;
    }
    else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    _tableView.frame = CGRectMake(0, TOP_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - TOP_HEIGHT);
//    _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshData)];
//    _tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    [self.view addSubview:_tableView];
}



- (void)dealloc {
#ifdef DEBUG
    NSLog(@"##########  %@ dealloc", NSStringFromClass(self.class));
#endif
}

@end
